﻿using Domain.Entities.Loggers;
using FluentMigrator;
using FrameworkCore.Extensions;

namespace Domain.Migrations.AuditTrails;

[Migration(202412270014)]
public class LoggerAddColumn : ForwardOnlyMigration
{
    public override void Up()
    {
        Alter.Table(MigrationExpressions.GetTableName(typeof(Logger)))        
          .AddColumn(MigrationExpressions.ColumnNameFor<Logger>(nameof(Logger.CustomerId))).AsInt64().Nullable().WithColumnDescription("用户主键")
          .AddColumn(MigrationExpressions.ColumnNameFor<Logger>(nameof(Logger.Timestamp))).AsDateTime().Nullable().WithColumnDescription("时间")
          .AddColumn(MigrationExpressions.ColumnNameFor<Logger>(nameof(Logger.TimestampLong))).AsInt64().Nullable().WithColumnDescription("时间戳")
          .AddColumn(MigrationExpressions.ColumnNameFor<Logger>(nameof(Logger.Level))).AsString(20).Nullable().WithColumnDescription("日志等级")
          .AddColumn(MigrationExpressions.ColumnNameFor<Logger>(nameof(Logger.MessageTemplate))).AsString(int.MaxValue).Nullable().WithColumnDescription("日志消息模板")
          .AddColumn(MigrationExpressions.ColumnNameFor<Logger>(nameof(Logger.Message))).AsString(int.MaxValue).Nullable().WithColumnDescription("消息")
          .AddColumn(MigrationExpressions.ColumnNameFor<Logger>(nameof(Logger.Exception))).AsString(int.MaxValue).Nullable().WithColumnDescription("异常消息")
          .AddColumn(MigrationExpressions.ColumnNameFor<Logger>(nameof(Logger.Properties))).AsString(int.MaxValue).Nullable().WithColumnDescription("Properties");
    }
}
